//
//  EJAssetModifyModel.m
//  EJPhotoBrowser
//
//  Created by 刘爽 on 2020/5/30.
//  Copyright © 2020 LiuShuang. All rights reserved.
//

#import "EJAssetModifyModel.h"

@implementation EJAssetModifyModel

- (BOOL)isEqual:(id)object {
    if (object == nil) {
        return NO;
    }
    if (![object isKindOfClass:[self class]]) {
        return NO;
    }
    EJAssetModifyModel * item = (EJAssetModifyModel *)object;
    if (item.asset == nil && self.asset == nil) {
        if ([item.image isEqual:self.image]) {
            return YES;
        }
    }
    if (![self.asset.localIdentifier isEqualToString:item.asset.localIdentifier]) {
        return NO;
    }
    return YES;
}

- (id)copyWithZone:(NSZone *)zone {
    EJAssetModifyModel * copy = [[EJAssetModifyModel allocWithZone:zone] init];
    copy.asset = self.asset;
    copy.image = self.image;
    copy.ext = [self.ext copy];
    return copy;
}

- (id)mutableCopyWithZone:(NSZone *)zone {
    EJAssetModifyModel * copy = [[EJAssetModifyModel allocWithZone:zone] init];
    copy.asset = self.asset;
    copy.image = self.image;
    copy.ext = [self.ext copy];
    return copy;
}

- (void)setImage:(UIImage *)image {
    _image = image;
    if (image == nil) {
        _modifyDate = nil;
    } else {
        _modifyDate = [NSDate date];
    }
}

@end
